package com.linq.cool.api.domain;

import com.baomidou.mybatisplus.annotation.*;
import com.linq.cool.common.core.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * @Author: yqlin
 * @Date: 2020/12/29 19:21
 * @Description: 角色信息表
 * @Version: 1.0.0
 */
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
@Data
@Accessors(chain = true)
@TableName(value = "sys_role")
public class SysRole extends BaseEntity implements Serializable {

    private static final long serialVersionUID = 136548812234948208L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 角色名称
     */
    @TableField(value = "`name`")
    private String name;

    /**
     * 角色权限字符串
     */
    @TableField(value = "perm_code")
    private String permCode;

    /**
     * 显示顺序
     */
    @TableField(value = "sort")
    private Integer sort;

    /**
     * 数据范围（1：全部数据权限 2：自定义数据权限 3：本部门数据权限 4：本部门及以下数据权限）
     */
    @TableField(value = "data_scope")
    private Integer dataScope;

    /**
     * 菜单树选择项是否关联显示（ 0：父子不互相关联显示 1：父子互相关联显示）
     */
    @TableField(value = "menu_check_strictly")
    private boolean menuCheckStrictly;

    /**
     * 部门树选择项是否关联显示（0：父子不互相关联显示 1：父子互相关联显示)
     */
    @TableField(value = "dept_check_strictly")
    private boolean deptCheckStrictly;

    /**
     * 角色状态（0:正常 1:停用）
     */
    @TableField(value = "`status`")
    private Integer status;

    /**
     * 删除标志（0:存在 1:删除）
     */
    @TableLogic
    @TableField(value = "is_deleted")
    private Integer isDeleted;

    /**
     * 备注
     */
    @TableField(value = "remark")
    private String remark;


    public SysRole(Long id) {
        this.id = id;
    }

    public static boolean isAdmin(Long id) {
        return id != null && 1L == id;
    }

    public boolean isAdmin() {
        return isAdmin(this.id);
    }

    public boolean isDeptCheckStrictly() {
        return deptCheckStrictly;
    }


    public boolean isMenuCheckStrictly() {
        return menuCheckStrictly;
    }


}